<?php

require_once 'Zend/Controller/Plugin/Abstract.php';

/*
 * 根据不同的模块取到不同的Layout
 */

class Custom_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstract

{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {

        $module = $request->getModuleName();
        
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
     
        $view = $viewRenderer->view;
       
        $moduleParams = $view->$module;
        $view->addBasePath($moduleParams['basePath']);
        $view->addHelperPath($moduleParams['helperPath'],
        $moduleParams['helperPathPrefix']);
        $layout = $view->layout();
        $layout->setLayoutPath($moduleParams['layoutPath'])
               ->setLayout($moduleParams['layout']);
    }

}

